home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
machack
/
Hacks96
/
FlyPaper.sit
/
Fly Paper
/
FlyPaper Source
/
Extension Sources
/
FlyPaperINIT.c
next >
Wrap
Text File
|
1996-06-22
|
3KB
|
103 lines
#ifndef FLYPAPERINIT_H
#include "FlyPaperINIT.h"
#endif
#ifndef __A4STUFF__
#include <A4Stuff.h>
#endif
#define _DragDispatch 0xABED
#define kSuccessIconID 128
#define kFailureIconID 129
#define kFlyCursor1ResID 128
#define kFlyCursor2ResID 129
FlyPaperGestaltRec gFlyPaperData;
static
pascal OSErr myGestaltRoutine (long /* selector */, FlyPaperGestaltPtr *result)
{
EnterCodeResource ();
*result = &gFlyPaperData;
ExitCodeResource ();
return (noErr);
}
static asm
void myDragDispatch (void)
{
MOVE.L A4,-(SP) // -4 stash A4
PEA 8(SP) // -8 push pointer to last param
MOVE.W D0, -(SP) // -A push selector
JSR SetCurrentA4 // setup A4
TST.W gFlyPaperData.enabled // if disabled don't patch
BEQ cleanup
MOVE.L gFlyPaperData.flyPaperCode, A0 // get code handle
MOVE.L (A0), A0 // deref
JSR (A0) // call code
cleanup:
MOVE.W (SP)+, D0 // -8 restore selector
ADDQ.L #4, SP // -4 pop param
MOVE.L gFlyPaperData.realDragManager, A0 // ROM address
MOVE.L (SP)+, A4 // 0 restore A4
JMP (A0) // call real drag manager
}
void main (void)
{
EnterCodeResource ();
Handle me = Get1Resource ('INIT', 129);
Boolean success = false;
Handle showINITCode;
Handle cursor;
if (!me)
goto Exit;
if (Button ())
goto Exit;
gFlyPaperData.enabled = false;
gFlyPaperData.flyPaperCode = Get1Resource (kFlyPaperResType, kFlyPaperResID);
if (gFlyPaperData.flyPaperCode == nil)
goto Exit;
if (NewGestalt (kSignature, (SelectorFunctionUPP) myGestaltRoutine))
goto Exit;
cursor = Get1Resource ('CURS', kFlyCursor1ResID);
if (!cursor)
goto Exit;
BlockMoveData (*cursor, &gFlyPaperData.flyCursors [0], sizeof (Cursor));
cursor = Get1Resource ('CURS', kFlyCursor2ResID);
if (!cursor)
goto Exit;
BlockMoveData (*cursor, &gFlyPaperData.flyCursors [1], sizeof (Cursor));
gFlyPaperData.magicWindow = nil;
DetachResource (gFlyPaperData.flyPaperCode);
gFlyPaperData.realDragManager = GetToolTrapAddress (_DragDispatch);
SetToolTrapAddress ((UniversalProcPtr) myDragDispatch, _DragDispatch);
success = true;
Exit:
showINITCode = Get1Resource ('SHOW', 128);
if (success) {
DetachResource (me);
gFlyPaperData.enabled = true;
if (showINITCode)
((pascal void (*) (short, Boolean)) *showINITCode) (kSuccessIconID, true);
} else if (gFlyPaperData.flyPaperCode) {
DisposeHandle (gFlyPaperData.flyPaperCode);
if (showINITCode)
((pascal void (*) (short, Boolean)) *showINITCode) (kFailureIconID, true);
}
ExitCodeResource ();
}